<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>ProjectGroup List</title>
    </head>
    <body>
        <div class="nav">
	<span class="menuButton"><g:link class="home" controller="person" action="home">Home</g:link></span>
        <g:if test="${session.user.role.name == 'Organiser'}">
            <span class="menuButton"><g:link class="create" action="create">New ProjectGroup</g:link></span>
	</g:if>
        <g:if test="${session.user.role.name == 'Student'}">
            <span class="menuButton"><g:link class="create" controller="project" action="create">New Project</g:link></span>
	</g:if>
	
        </div>
        <div class="body">

            
		<g:set var="tProject" value="${session.user.chosenProject()}"/>
		<g:if test="${tProject}">
		<h1>You current project choice is:</h1> <h3>${tProject}</h3>
		<br />
		<h1>Your supervisor is:</h1> <h3>Dr. ${tProject.supervisor}</h3> 
		<br />
		<h1>project code is:</h1> <h3>${tProject.projectCode}</h3>
		</g:if>	
		<br />
                <g:if test="${session.user.role.name == 'Student'}"> 
		<p>
		<h4>You can only choose one project for your dissertation. If you want to change your project choice, then you can choose other project, but your prevoious project choice will become available for other students to choose</h4>
		</p> 
		<br />
		<h1>ProjectGroup List</h1>
		</g:if>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                       	   <g:if test="${session.user.role.name == 'Organiser'}"> 
                   	        <g:sortableColumn property="id" title="Id" />
                           </g:if>
                   	        <g:sortableColumn property="code" title="Code" />
                        
                   	        <g:sortableColumn property="name" title="Name" />
                        
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${projectGroupList}" status="i" var="projectGroup">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        <g:if test="${session.user.role.name == 'Organiser'}">
                            <td><g:link action="show" id="${projectGroup.id}">${fieldValue(bean:projectGroup, field:'id')}</g:link></td>
                        </g:if>
                            <td>${fieldValue(bean:projectGroup, field:'code')}</td>
                        
                            <td><g:link controller="project" action="list" params="[projectGroupId:projectGroup.id]">${fieldValue(bean:projectGroup, field:'name')}</g:link></td>
                        
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
		<input type="button" value="Back" onClick="history.back()">
            </div>
        </div>
    </body>
</html>
